//获取应用实例
var app = getApp();
Page({
	data: {
		userInfo:{},
		hiddenlogin:true,
		is_member:0,
		isimg:'',
		cardhao:'',
		qrcode:'',
		toast_show: false,
		title:'恭喜您抽中了',
		content:'"新唐势力开业礼',
		description:'请在我的卡券当中进行查看',
		button:'去查看'
	},
	onLoad:function(){

	},
	onShow:function(){
		let that = this
		app.request('/api/Member/getMemberInfo', {}, function(res){
			if(res.code == '0'){
				that.setData({
					isimg:res.data.HYXX.iHYKTYPE,
					cardhao:res.data.HYXX.sHYK_NO,
					qrcode:res.data.HYXX.qrcode,
					is_member:1,
					userInfo:wx.getStorageSync('wechat')
				});
				wx.setStorageSync('is_member', 1);
			}else{
				wx.setStorageSync('is_member', 0);
			}
		});
		that.setData({
			toast_show:false,
		})
		var toast_content = wx.getStorageSync('price_data')
		if(toast_content.toast_show){
			if(toast_content.content.length == 1){
				that.setData({
					toast_show: true,
					content: toast_content.content[0],
					button: toast_content.btn_title,
					description: toast_content.description
				})
			}else if(toast_content.content.length == 2){
				that.setData({
					toast_show: true,
					content: toast_content.content[0]+'和'+toast_content.content[1],
					button: toast_content.btn_title,
					description: toast_content.description
				})
			}
		}
	},
	close_toast:function(){
		var that = this;
		wx.setStorageSync('price_data',[]);
		that.setData({
			toast_show:false
    	})
	},
	go_mycoupon:function() {
		let that = this
		wx.setStorageSync('price_data',[]);
		that.setData({
			toast_show:false
    	})
    	if(that.data.button == '去查看'){
    		wx.navigateTo({
	           url:'/pages/mycoupon/mycoupon'
	        })
    	}else{
    		that.close_toast()
    	}
	},
	//查看二维码
	imgYu:function(){
		wx.previewImage({
		    current:this.data.qrcode,
		    urls:[this.data.qrcode]
		})
	},
	//显示登录框
	login:function(){
		this.setData({
			hiddenlogin:false
		});
	},
	//微信登录回调
	bindGetUserInfo:function(e){
		var that = this;
		that.setData({
			hiddenlogin:true
		});
		if(e.detail.errMsg == "getUserInfo:ok"){
			app.watchLogin(function(res){
				if(res.ismember == 1){
					that.onShow();
				}else{
					wx.navigateTo({
					   url:'/pages/login/login'
					})
				}
			});
		}
	},
	//取消登录
	cancel:function(){
		this.setData({
			hiddenlogin:true
		});
	},
	//客服电话
	dialing:function(event){
		wx.makePhoneCall({
			phoneNumber:'029-84256363'
		})
	},
	signup:function(){
		if(this.data.is_member == 1){
			wx.navigateTo({
			   url:'/pages/sign/sign'
			})
		}else{
			this.login();
		}
	},
	cpupon:function(){
		if(this.data.is_member == 1){
			wx.navigateTo({
			   url:'/pages/discount/discount'
			})
		}else{
			this.login();
		}
	},
	game:function(){
		if(this.data.is_member == 1){
			wx.navigateTo({
			   url:'/pages/gamePage/gamePage'
			})
		}else{
			this.login();
		}
	},
	car:function(){
		if(this.data.is_member == 1){
			wx.navigateTo({
			   url:'/pages/parkrecord/parkrecord'
			})
		}else{
			this.login();
		}
	},
	mall:function(){
		if(this.data.is_member == 1){
			wx.navigateTo({
			   url:'/pages/integralmall/integralmall'
			})
		}else{
			this.login();
		}
	},
	ticket:function(){
		if(this.data.is_member == 1){
			wx.navigateTo({
			   url:'/pages/uploadticket/uploadticket'
			})
		}else{
			this.login();
		}
	},
	integral:function(){
		if(this.data.is_member == 1){
			wx.navigateTo({
			   url:'/pages/myintegral/myintegral'
			})
		}else{
			this.login();
		}
	},
	cards:function(){
		if(this.data.is_member == 1){
			wx.navigateTo({
			   url:'/pages/mycoupon/mycoupon'
			})
		}else{
			this.login();
		}
	},
	order:function(){
		if(this.data.is_member == 1){
			wx.navigateTo({
			   url:'/pages/myorder/myorder'
			})
		}else{
			this.login();
		}
	},
	activity:function(){
		if(this.data.is_member == 1){
			wx.navigateTo({
			   url:'/pages/activitylist/activitylist'
			})
		}else{
			this.login();
		}
	}
})